Memory management is a common function of virtual machines. Traditional managed memory systems track dynamically allocated memory corresponding to a single type of memory resource (i.e., object pointers). Common memory management tasks, such as dynamic memory allocation, may be performed by a memory management component (or a garbage collector) of the virtual machine or operating system. The memory management component may also track and reclaim memory which is no longer used.
Traditional garbage collectors are used to track dynamically allocated memory objects in heap memory. Unmanaged memory systems place the burden of memory de-allocation with the programmer. Programmers must carefully plan the lifecycle of dynamically allocated memory objects such that objects are accessible when required and subsequently de-allocated before they can no longer be accessed by running code. If references to memory objects are lost before the memory is released to the operating system, a program may experience an accumulation of inaccessible memory resulting in a memory leak.
One fundamental inefficiency of managed memory systems is the problem of fragmentation. Fragmentation of memory is a symptom of inefficient use of memory resources. Specifically, fragmentation occurs when multiple memory allocations, either in physical or virtual memory, leave gaps of unused memory between allocated memory segments. In some cases, these contiguous segments (i.e., “gaps”) of unused memory are too small to be allocated for use by the memory management module. Furthermore, unmanaged memory resources cannot be modified or moved in order to defragment or compact the memory. Memory fragmentation can lead to performance degradation and premature exhaustion in the management of memory resources.